<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{$title} - {:config('sitename')}</title>
    <meta name="keywords" content="{:config('keywords')}"/>
    <meta name="description" content="{:config('description')}"/>
    <link href="//cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="//cdn.jsdelivr.net/npm/simple-line-icons@2.4.1/css/simple-line-icons.css" rel="stylesheet">
    <link href="/Static/css/img.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-fixed-top navbar-default">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">导航按钮</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">{:config('sitename')}</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/"><span class="icon-home"></span> 首页</a></li>
                <li><a href="/{:ADMIN_DIR}/login"><span class="icon-user"></span> 登录</a></li>
            </ul>
        </div>
    </div>
</nav>
<div class="container" style="padding-top:70px;">
    <div class="col-xs-12 col-sm-10 col-md-8 col-lg-8 center-block" style="float: none;">
        <div class="panel panel-default">
            <div class="panel-heading">{$title}</div>
            <div class="panel-body">
                <form id="form">
                    <div class="form-group">
                        <label>用户名</label>
                        <input type="text" class="form-control" name="username" placeholder="请输入用户名">
                    </div>
                    <div class="form-group">
                        <label>密码</label>
                        <input type="password" class="form-control" name="password" placeholder="请输入密码">
                    </div>
                </form>
                <button type="submit" class="btn btn-default" onclick="login()">登录</button>
            </div>
        </div>
    </div>
</div>
<footer class="footer">
    <div class="container">
        <div class="col-lg-8 pull-left">
            <p class="text-muted">
                Copyright © {:date("Y", time())} <span class="glyphicon glyphicon-heart" style="color:red;"></span>
                {:config('copy')}
            </p>
        </div>
        <div class="col-lg-4 pull-right">
            <p class="text-muted">
                {:config('footer')}
            </p>
        </div>
    </div>
</footer>
<script src="//cdn.jsdelivr.net/npm/jquery@2.1.3/dist/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/bootstrap-fileinput@5.1.2/js/fileinput.min.js"></script>
<script src="//cdn.jsdelivr.net/gh/sentsin/layer/src/layer.js"></script>
<script src="/Static/js/img.js"></script>
<script>
    var enter = true;

    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            if (enter) {
                login();
            } else {
                window.location.href = "/{:ADMIN_DIR}";
            }
        }
    });

    function login() {
        var cont = $('#form').serialize();
        $.ajax({
            url: '/{:ADMIN_DIR}/do_login',
            type: 'POST',
            data: cont,
            dataType: 'json',
            success: function (res) {
                if (res.code != 1) {
                    layer.msg(res.msg);
                    return false;
                }
                enter = false;
                layer.alert(res.msg, function () {
                    window.location.href = '/{:ADMIN_DIR}';
                });
            },
            error: function () {
                layer.msg('网络错误！');
            }
        });
    }
</script>
</body>
</html>